////////////////////////////////////////////////////////////////////////////////
//
//  Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
//  All Rights Reserved. The following is Source Code and is subject to all
//  restrictions on such code as contained in the End User License Agreement
//  accompanying this product.
//
////////////////////////////////////////////////////////////////////////////////

package mx.charts.chartClasses
{

import flash.events.EventDispatcher;
import flash.events.Event;

/**
 *  The AxisBase class serves as a base class
 *  for the various axis types supported in Flex. 
 *
 *  @mxml
 *  
 *  <p>Flex components inherit the following properties
 *  from the AxisBase class:</p>
 * 
 *  <pre>
 *  &lt;mx:<i>tagname</i>
 *    name="<i>No default</i>"
 *  &gt;
 *  </pre>
 */
public class AxisBase extends EventDispatcher
{
    include "../../core/Version.as";

	//--------------------------------------------------------------------------
	//
	//  Constructor
	//
	//--------------------------------------------------------------------------

	/**
	 *  Constructor.
	 */
	public function AxisBase()
	{
		super();
	}

	//--------------------------------------------------------------------------
	//
	//  Variables
	//
	//--------------------------------------------------------------------------
	
	/**
	 *  @private
	 */
	protected var _transforms:Array = [];
	
	//--------------------------------------------------------------------------
	//
	//  Properties
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	//  chartDataProvider
	//----------------------------------

	[Inspectable(environment="none")]

	/**
	 *  @copy mx.charts.chartClasses.IAxis#chartDataProvider
	 */
	public function set chartDataProvider(value:Object):void
	{
	}

	//----------------------------------
	//  name
	//----------------------------------

	/**
	 *  @private
	 *  Storage for the name property.
	 */
	private var _displayName:String = "";

    [Inspectable(category="Display")]

	/**
	 *  @copy mx.charts.chartClasses.IAxis#displayName
	 */
	public function get displayName():String
	{
		return _displayName;
	}
	
	/**
	 *  @private
	 */
	public function set displayName(value:String):void
	{
		_displayName = value;
	}
	
	//----------------------------------
	//  title
	//----------------------------------

	/**
	 *  @private
	 *  Storage for the title property.
	 */
	private var _title:String = "";

    [Inspectable(category="General")]
	
	/**
	 *  @copy mx.charts.chartClasses.IAxis#title
	 */
	public function get title():String
	{
		return _title;
	}
	
	/**
	 *  @private
	 */
	public function set title(value:String):void
	{
		dispatchEvent(new Event("titleChange"));

		_title = value;
	}

	//----------------------------------
	//  unitSize
	//----------------------------------

	[Inspectable(environment="none")]

	/**
	 *  @copy mx.charts.chartClasses.IAxis#unitSize
	 */
	public function get unitSize():Number
	{
		return 1;
	}
	
	//--------------------------------------------------------------------------
	//
	//  Methods
	//
	//--------------------------------------------------------------------------

	/**
	 *  @copy mx.charts.chartClasses.IChartElement#describeData()
	 */
	protected function describeData(requiredFields:uint):Array
	{
		var result:Array = [];
		
		for (var i:int = 0; i < _transforms.length; i++)
		{
			result = result.concat(
				_transforms[i].transform.describeData(
					_transforms[i].dimension, requiredFields));
		}
		
		return result;
	}

	/**
	 *  @copy mx.charts.chartClasses.IAxis#registerDataTransform()
	 */
	public function registerDataTransform(transform:DataTransform,
										  dimensionName:String):void
	{
		_transforms.push({ transform:transform, dimension: dimensionName });
		
		dataChanged();
	}
	
	/**
	 *  @copy mx.charts.chartClasses.IAxis#unregisterDataTransform()
	 */
	public function unregisterDataTransform(transform:DataTransform):void
	{
		for (var i:int = 0; i < _transforms.length; i++)
		{
			if (_transforms[i].transform == transform)
			{
				_transforms.splice(i, 1);
				break;
			}
		}

		dataChanged();
	}
	
	/**
	 *  @copy mx.charts.chartClasses.IAxis#dataChanged()
	 */
	public function dataChanged():void
	{
	}
}

}
